Figure 1

The Figure 1 is the showcase for geomeTriD package to present multiple genomic signals along with 3D models in different layout.

Load Libraries

library(geomeTriD)
library(geomeTriD.documentation)
library(GenomicRanges)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(trackViewer)

Prepare the annotation and genomic data

The data were downloaded from ENCODE for GM12878 with assembly hg19. The 3D structure model were downloaded from FLAMINGO results for GEO dataset with accession GSE63525.

chr <- 'chr4'
range <- as(seqinfo(TxDb.Hsapiens.UCSC.hg19.knownGene)[chr], 'GRanges')
prefix <- 'https://www.encodeproject.org/files/'
url <- c(#ctcf = 'ENCFF364OXN/@@download/ENCFF364OXN.bigWig',
         #smc3 = 'ENCFF235BXX/@@download/ENCFF235BXX.bigWig',
         #rad21 = 'ENCFF567EGK/@@download/ENCFF567EGK.bigWig',
         #H3K4me3 = 'ENCFF674QZB/@@download/ENCFF674QZB.bigWig',
         #H3K27me3 = 'ENCFF594HSG/@@download/ENCFF594HSG.bigWig',
         H3K9me3 = 'ENCFF776OVW/@@download/ENCFF776OVW.bigWig',
         #H3K4me1 = 'ENCFF682WPF/@@download/ENCFF682WPF.bigWig',
         H3K27ac = 'ENCFF180LKW/@@download/ENCFF180LKW.bigWig')
urls <- paste0(prefix, url)
names(urls) <- names(url)
colorCode <- c('active'='#EA262E', 'inactive'='#179281')
# download the files and import the signals
genomicSigs <- importSignalFromUrl(urls, range = range,
                                   cols = list(
                                     'H3K9me3'=c('#000011', 'blue'),
                                     'H3K27ac'=c('#111100', 'orange')),
                                   format = 'BigWig')
## adding rname 'https://www.encodeproject.org/files/ENCFF776OVW/@@download/ENCFF776OVW.bigWig'
## adding rname 'https://www.encodeproject.org/files/ENCFF180LKW/@@download/ENCFF180LKW.bigWig'
# import the A/B compartments
compartments <- rtracklayer::import('https://ftp.ncbi.nlm.nih.gov/geo/series/GSE63nnn/GSE63525/suppl/GSE63525%5FGM12878%5Fsubcompartments.bed.gz')
compartments$col <- ifelse(is.na(compartments$name), 'gray', 
                           ifelse(grepl('^A', compartments$name),
                                  colorCode['active'],
                                  colorCode['inactive']))
compartments$label <- compartments$name
compartments$type <- 'compartment'
# import the 3D model generated by FLAMINGO
chrs <- paste0('chr', c(1:22, 'X'))
gm12878 <- paste0('https://github.com/wangjr03/FLAMINGO/',
                  'raw/refs/heads/main/predictions/GM12878/',
                  chrs, '_5kb.txt')
names(gm12878) <- chrs
gm12878.gl <- importFLAMINGO(gm12878)

Plot the data by geomeTriD

# create a list of threeJsGeometry objects
objsC <- view3dStructure(gm12878.gl[[chr]], # 3D model by FLAMINGO
                         k=3, # 3D
                         feature.gr=compartments[seqnames(compartments) %in%
                                                   chr], # subset of the compartments
                         genomicSigs = genomicSigs, # the histon markers
                         reverseGenomicSigs = FALSE, lwd.maxGenomicSigs = 10,
                         show_coor = FALSE, label_gene = FALSE,#close the labels
                         renderer = 'none', # return a list of objects
                         resolution = 1)
## top vs bottom layout
for(i in seq_along(objsC)){
  if(grepl('backbone|compartment', names(objsC)[i])){
    objsC[[i]]$layer <- 'bottom' ## put compartment and backbone to bottom layer
  }
}
threeJsViewer(objsC, background = 'black')